
from common.models.user import User, Users
import dzentity, dzpage, dzutil

#------------------------------------------------------------------------
class ShowView(dzentity.Entity):
    def __init__(self,user):
        self.user = user
        self.title = 'Profile'

    def render(self):
        page = dzpage.Page(dzutil.render('views/user_show.txt',self.user))
        page.actions = [
            dzutil.link_to('Edit',action='edit'),
            dzutil.link_to('Change Password',action='change_password'),
        ]
        page.title = self.title
        return page.render()

class EditView(ShowView):
    def render(self):
        page = dzpage.Page(dzutil.render('views/user_edit.txt',form=1,con='user',action='update',data=self.user))
        page.title = self.title
        return page.render()

class ChangePasswordView(ShowView):
    def render(self):
        page = dzpage.Page()
        self.user.OLD_PASSWORD = ''
        self.user.NEW_PASSWORD = ''
        self.user.CONFIRM = ''
        page.content = dzutil.render('views/user_change_password.txt',form=1,data=self.user,action='update_password')
        page.title = self.title
        return page.render()

